package cn.promonkey.core.toolkit;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;

import java.util.Collection;
import java.util.Map;

/** @author 郭晓宇 */
public class CommonUtils {

	public static boolean IsNoneBlank(Object... params) {
		for (Object param : params) {
			if (null == param)
				return false;
			if (param instanceof Integer) {
				if ((int) param < 0)
					return false;
			}
			if (param instanceof String) {
				if (StringUtils.isBlank(String.valueOf(param)))
					return false;
			}
		}
		return true;
	}

	public static boolean isEmpty(final Object params) {
		return !isNotEmpty(params);
	}

	public static boolean isNotEmpty(final Object params) {
		if (null != params) {
			if (params instanceof Map) {
				Map<?, ?> map = (Map) params;
				return !map.isEmpty();
			} else if (params instanceof Collection) {
				Collection<?> coll = (Collection) params;
				return !coll.isEmpty();
			} else if (params instanceof CharSequence) {
				CharSequence cs = (CharSequence) params;
				int strLen;
				if ((strLen = cs.length()) == 0) {
					return false;
				}
				for (int i = 0; i < strLen; i++) {
					if (Character.isWhitespace(cs.charAt(i))) {
						return false;
					}
				}
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

}
